cmake_minimum_required(VERSION 3.20)

# # Set C compiler to Clang
# set(CMAKE_C_COMPILER "clang")
#
# # Set C++ compiler to Clang++
# set(CMAKE_CXX_COMPILER "clang++")

# opencv lib for VS was compiled in cxx11
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CUDA_FLAGS "-allow-unsupported-compiler -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH")

if("${CMAKE_BUILD_TYPE}" STREQUAL "")
    set(CMAKE_BUILD_TYPE "Debug")
endif() # CMAKE_BUILD_TYPE

set(CMAKE_USE_CUDA_WARD_SENSE ON)

if(CMAKE_USE_CUDA_WARD_SENSE)
project(ward-sense
    LANGUAGES C CXX CUDA
    DESCRIPTION "ward-sense"
)
add_definitions(-D__USE_CUDA_WARD_SENSE__)
else()
project(ward-sense
    LANGUAGES C CXX
    DESCRIPTION "ward-sense"
)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
    message(STATUS "MSVC compiler detected, adding /utf-8 option.")
    add_compile_options(/utf-8)
endif()

if(PROJECT_BINARY_DIR STREQUAL PROJECT_SOURCE_DIR)
    message(WARNING "The binary directory of CMake cannot be the same as source directory!")
endif() # project dir

if(WIN32)
    add_definitions(-DNOMINMAX -D_USE_MATH_DEFINES)
endif() # WIN32

include(3rdlibs/find.cmake)
add_subdirectory(src)
